﻿Imports Microsoft.AspNet.Membership.OpenAuth, System.Data.OleDb

Public Class Register
    Inherits Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        RegisterUser.ContinueDestinationPageUrl = Request.QueryString("ReturnUrl")
    End Sub

    Protected Sub RegisterUser_CreatedUser(ByVal sender As Object, ByVal e As EventArgs) Handles RegisterUser.CreatedUser
        FormsAuthentication.SetAuthCookie(RegisterUser.UserName, createPersistentCookie:=False)

        Dim continueUrl As String = RegisterUser.ContinueDestinationPageUrl
        If Not OpenAuth.IsLocalUrl(continueUrl) Then
            continueUrl = "~/"
        End If

        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("travelConnectionString").ConnectionString)
        Dim SqlString As String = "Insert Into Profile(VisitorId) Values (@f1)"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        oleDbConn.Open()
        'Dim myGUID, myGUID2 As New System.Guid
        'myGUID = Guid.NewGuid()
        'myGUID2 = Guid.NewGuid()
        'Dim newFileName = myGUID.ToString() + ".jpg"
        'Dim newFileName2 = myGUID2.ToString() + ".jpg"

        ' If F_Picture.HasFile Then
        'F_Picture.SaveAs(Request.MapPath("pictures") & "/" & newFileName)
        'Using OriginalImage = Image.FromFile(Request.MapPath("pictures") & "/" & newFileName)
        'Using ResizedImage As New Bitmap(OriginalImage, 500, 500)
        'ResizedImage.Save(Request.MapPath("pictures") & "/" & newFileName2, Drawing.Imaging.ImageFormat.Jpeg)

        'End Using
        'End Using
        'End If
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@f1", RegisterUser.UserName)
        cmd.ExecuteNonQuery()
        Response.Redirect("~/editProfile.aspx")
    End Sub
End Class